package com.softer.chengxin.syshome.dao;


import com.softer.chengxin.syshome.entity.SysModule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zcz
 * @date 2018/12/26
 */
@Mapper
@Repository
public interface SysHomeDao {

    /**
     * 根据账号查询菜单资源
     * @param loginName
     * @return
     */
    @Select("SELECT id AS Id,operation AS operation,type AS type,structure AS structure, module_name AS  ModuleName , parent_id AS ParentId, url AS Url, icon AS Icon, sort AS Sort FROM module WHERE FIND_IN_SET(structure,(SELECT b.mo_dules FROM manager_user AS a,roules AS b WHERE a.role_id=b.id  AND a.login_name=#{loginName}))")
    List<SysModule> selectSysModuleByLoginName(String loginName);
    /**
     * 根据dicCode查询菜单资源
     * @param dicCode
     * @return
     */
    @Select("SELECT id AS Id,operation AS operation,structure AS structure, module_name AS  ModuleName ,type, parent_id AS ParentId, url AS Url, icon AS Icon, sort AS Sort FROM module WHERE FIND_IN_SET(structure,(SELECT b.mo_dules FROM roules AS b WHERE b.dic_code = #{dicCode}))")
    List<SysModule> selectSysModuleByDicCode(String dicCode);

}
